package com.javaee.ch10.web;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Validated
@RestController
@RequestMapping("/api/user")
public class UserController {
    @GetMapping("/")
    public List list() {

        List<User> users = new ArrayList<>();
        // 初始化示例数据
        users.add(new User(1, "johnDoe", "john@example.com", "+1-202-555-0144"));
        users.add(new User(2, "janeSmith", "jane@example.com", "+1-202-555-0145"));
        users.add(new User(3, "bobJohnson", "bob@example.com", "+1-202-555-0146"));
        return users;
    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class User {
    private int id;
    private String username;
    private String email;
    private String phone;
}


